<?php !defined("IN_SYSTEM") && exit("ACCESS DENY");?>
{template header}
{template top}
<div id="uc">
{template uc/left}
	<div id="uc_main">
		<div class="uc_tab">
			<ul>
			<li><span><a{if !isset($action) || $action == 'inbox'} class="on"{/if} href="{url('home.php?f=msg&a=inbox')}">{$lang['inbox']}</a></span></li>
			<li><span><a{if $action == 'outbox'} class="on"{/if} href="{url('home.php?f=msg&a=outbox')}">{$lang['outbox']}</a></span></li>
			<li><span><a{if $action == 'add'} class="on"{/if} href="{url('home.php?f=msg&a=add')}">{$lang['add_msg']}</a></span></li>
			</ul>
		</div>
		<div id="uc_contain">
		{if $action == 'outbox' || $action == 'inbox' || !$action}
			<table class="uc_table" >
				<tr>
				<th style="width:120px;">{if $action == 'outbox'}{$lang['receiver']}{else}{$lang['sender']}{/if}</th><th style="width:90px;">{$lang['time']}</th><th>{$lang['contant']}</th><th style="width:50px;">{$lang['status']}</th>
				<th style="width:80px;">{$lang['operation']}</th>
				</tr>
			{loop $msgs $msg}
			<tr id="tr{$msg['pmid']}">
			<td>{$msg['username']}</td>
			<td>{gdate('H:i,n'.$lang['month'].'d',$msg['posttime'])}</td>
			<td>{$msg['content']}</td>
			<td>{$msg_status[$msg['new']]}</td>
			{if $action == 'outbox'}
			<td>-</td>
			{else}
			<td><a href="{url("home.php?f=msg&a=del&ajax=1&id=". $msg['pmid'])}" onclick="return deletemsg(this.href,'tr{$msg['pmid']}');" target="_blank">[{$lang['delete']}]</a></td>
			{/if}
			</tr>
			{/loop}
			</table>
			{$pager}
		
			<script type="text/javascript">
	
				function deletemsg(u,id){
					if(confirm('{$lang["confirm_delete"]}')){
						$.getJSON(u+'&tm='+Math.random(),'',function(data){
							if(data.status==true){
								$('#'+id).hide();
							}else{
								alert(data.msg);
							}
							});
					}
					return false;
					
				}
			</script>
		{/if}
		{if $action == 'add' || $action == 'edit'}
			<form name="friend_add" method="post" action="{url('home.php?f=msg&a=add')}" enctype="multipart/form-data">
			<table cellspacing="0" class="uc_fa_table">
			<tr>
			<td class="td1">{$lang['receiver']}：</td>
			<td colspan="3">
			<a title="{$lang['select_from_friend_list']}" onclick="$('#myfriendlistdiv').show('quick');" class="down" href="javascript:;">{$lang['select_friend']}</a>
			<div id="friendsdiv" onclick="$('#receiver').focus();" >
			
			<input type="text" value="{$lang['input_friend_name']}" onclick="if(this.value=='{$lang['input_friend_name']}')this.value='';" class="input" name="receiver" id="receiver" /> 
			</div>
			<div>
			
			
			
			
			
			<div style="position: absolute;background:#fff; padding: 10px;width:360px;border:1px solid #d2d2d2;display:none;" unselectable="on" id="myfriendlistdiv" >
<div style="margin-bottom:5px;border-bottom:1px solid #d2d2d2;padding-bottom: 10px;">
<select onchange="myfriendlist(this.value)">
<option value="-1">{$lang['all_friend']}</option>
{loop $group $k $v}
<option value="{$k}">{$v}</option>
{/loop}
</select>
</div>
<div style="height: 134px;overflow-y:auto;">
<ul id="msgfriend">
<li><label><input type="checkbox" onclick="selectfriend(this,'')" value="synge0112" id="chk12351" name="friends[]"> <span>synge0112</span></label></li>
<li><label><input type="checkbox" class="pc" onclick="if(this.checked){ fs.selectUserName(this.value); } else { fs.delSelUser('uid12905'); }" value="ASUS、宝宝" id="chk12905" name="selUsers[]"> <span class="xi2">ASUS、宝宝</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) { fs.selectUserName(this.value); } else { fs.delSelUser('uid13013'); }" value="紫梦倾国" id="chk13013" name="selUsers[]"> <span class="xi2">紫梦倾国</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) { fs.selectUserName(this.value);} else {fs.delSelUser('uid20889'); }" value="放牧童的小牛" id="chk20889" name="selUsers[]"> <span class="xi2">放牧童的小牛</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) {fs.selectUserName(this.value);} else {fs.delSelUser('uid12794');}" value="幼殇" id="chk12794" name="selUsers[]"> <span class="xi2">幼殇</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) {fs.selectUserName(this.value);} else {fs.delSelUser('uid16627');}" value="奔跑的乌龟" id="chk16627" name="selUsers[]"> <span class="xi2">奔跑的乌龟</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) {fs.selectUserName(this.value);} else {fs.delSelUser('uid12172');}" value="test" id="chk12172" name="selUsers[]"> <span class="xi2">test</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) {fs.selectUserName(this.value);} else {fs.delSelUser('uid10915');}" value="JSCZZYX" id="chk10915" name="selUsers[]"> <span class="xi2">JSCZZYX</span></label></li><li><label><input type="checkbox" class="pc" onclick="if(this.checked) {fs.selectUserName(this.value);} else {fs.delSelUser('uid10277');}" value="水晶枫" id="chk10277" name="selUsers[]"> <span class="xi2">水晶枫</span></label></li></ul>
</div>
<div style="text-align:right;">
<button onclick="$('#myfriendlistdiv').hide('slow');"  type="button"><span>关闭</span></button>
</div>
</div>
<script type="text/javascript">
function myfriendlist(id){
	$.getJSON("home.php?f=friend&a=ajaxlist&id="+id+'&tm='+Math.random(),'', function(rq){
		 	if(rq.status == true){
			 	var s="";
		 		 $.each(rq.data, function(i,item){
			 		 s +='<li><label><input type="checkbox" onclick="selectfriend(this)" value="'+item.name+'" id="fid'+item.fuid+'" name="friends[]"> <span>'+item.name+'</span></label></li>';
		 		 });
			 		$('#msgfriend').html(s);
		 	}else{
				$('#msgfriend').html("<li>{$lang['gid_no_friend']}</li>");
		 	}
		   
		  });
}
function selectfriend(obj){
	if(obj.checked){
		$('#u'+obj.id).remove();
		$('<span id="u'+obj.id+'"><a onclick="dropfriend(\'u'+obj.id+'\');" class="delf" href="javascript:;">{$lang['delete']}</a><em class="z">'+obj.value+'</em><input type="hidden" value="'+obj.id+'" name="friended[]"></span>').insertBefore($('#receiver'));
	}else{
		obj.checked=false;
		var fid = obj.id.substr(3);
		$('#ufid'+fid).remove();
	}
}
function dropfriend(id){
	$('#'+id).remove();
	var fid = id.substr(4);
	$('#fid'+fid).removeAttr("checked");
}
myfriendlist(-1);
</script>			
			
			
			
			
			
			</div>
			
			</td>
			</tr>
			<tr>
			<td class="td1">{$lang['contant']}：</td>
			<td colspan="3"><textarea  name="extra" cols="51" >{$data['extra']}</textarea></td>
			</tr>
		<tr class="bg2"><td></td><td colspan="3"><input type="submit" class="button" value="{$lang['send']}" /> </td></tr>
	</table>
	</form>
		
		{/if}
		
		
		</div>
	</div>

</div>


{template footer}